<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>新增pid</title>
        <link rel="stylesheet" href="__STATIC__/layui/css/layui.css" media="all">
        <script src="__STATIC__/index/js/jquery-3.2.1.js"></script>
        <script src="__STATIC__/layui/layui.js"></script>
    <style type="text/css">
		.dis_none{
			display: none;
		}
    </style>
    </head>
    <body>
        <form class="layui-form" style="padding: 20px 10px;"> <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">请发表建议</label>
                <input type="hidden" name="sp_id" id="sp_id" value="{$id}" />
                <div class="layui-input-block" style="border: 1px solid #389ce9;height:100px;">
        			<textarea class="layui-textarea" name="content" rows="30" cols="30" style="border: none;outline: none;height:100px;" placeholder="请客观发表你的评论，或者质疑！官网保留删帖的权利！"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block" style="overflow: hidden;">
                    <button class="layui-btn" lay-submit lay-filter="*" id="button_from" style="float: right;background: #1E9FFF;">提交</button>
                </div>
                <div style="margin-top:30px;border-bottom:solid #cbdae3 1px; padding-bottom:10px; overflow:hidden;">
			        <div style="width:24px; height:23px; background:url(__STATIC__/index/img/ping_icon.png); float:left;"></div>
			        <div style="float:left; font-size:17px; color:#333333; margin-left:10px;">大家都在说</div>
			        <div style="float:right; font-size:14px; color:#999999; ">请客观评论或者质疑哦 ^_^</div>
			    </div>
			    <div style="overflow:hidden; padding-bottom:20px; ">
        			<div>
        				{foreach $arr as $v}
                        <div style="margin-top:20px; padding-bottom:20px; border-bottom:dashed #c1d6e6 1px;">
	                		<div style="font-size:12px; color:#999999;">
	                			用户：<span style="font-family:Arial; color:#999999; margin-right:20px;">
	                    				{$v.mobile}
					  				</span>
					  			评论时间：<span style="font-family:Arial; color:#999999;">{$v.time|date="Y-m-d H:i:s",###}</span>
	                		</div>
		                    <div style="font-size:14px; color:#2c72a8; margin-top:10px;">
		                    	<span style="font-size:20px; margin-right:5px; font-family:'宋体';">
		                    	“</span>
		                    	{$v.content}
		                    	<span style="font-size:20px; margin-left:5px; font-family:'宋体';">”</span>
		                    	
		                    </div>
		                
		                    {if $v.reply==''}
		                    <div style="font-size:14px; color:#2c72a8; margin-top:10px;" class="dis_none">
		                    	商家回复：<span style="color: #2c72a8;">{$v.reply}</span>
		                    </div>
		                    {else}
		                    <div style="font-size:14px; color:#2c72a8; margin-top:10px;">
		                    	商家回复：<span style="color: #2c72a8;">{$v.reply}</span>
		                    </div>
		                    {/if}
                  		</div>
                  		{/foreach}
                  		
                  	</div>
    			</div>
          	</div>
            <!-- 更多表单结构排版请移步文档左侧【页面元素-表单】一项阅览 -->
        </form>
       
        <script>
            layui.use('form', function(){
                var form = layui.form;
                form.on('submit(*)', function(data){
                	//console.log(data);
                	var field = data.field;
                	var content =field.content;
                	var id = field.sp_id;
                	if(content==''){
        	              layui.use('layer', function(){
			              var layer = layui.layer;
			              layer.alert('请输入评论内容', {icon: 2})
			              });  	
			              return false;
                	}
                $('#button_from').attr('disabled','disabled');	 
               $.ajax({
                		type:"post",
                		url:"{:url('index/insert_review')}",
                		data:{content:content,id:id},
                		success:function(res){
                		   if(res.code==0){
	                		   	  layui.use('layer', function(){
					              var layer = layui.layer;
					              layer.alert(res.msg, {icon: 2},function(){
					              	$('#button_from').removeAttr('disabled');
					              	location.reload(); 
					              });
					              });              
			 		        return false;
                		   }else if(res.code==1){
                		   	       layui.use('layer', function(){
					               var layer = layui.layer;
					               layer.alert(res.msg, {icon: 1},function(){
					               	 //var index = parent.layer.getFrameIndex(window.name);
					               	  //parent.layer.close(index);
					               	  	location.reload(); 
					               });
					              });  
					        return false;
                		   }

                		}
                	});
                	
                    return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
                });
            });   
        </script>
    </body>
</html>
